<template>
    <div class="wrap">
        <form action="">
            <input type="number" name = 'phone' v-model="mobile" class="mobile" placeholder="请输入手机号">
             <input type="number" name = 'code' v-model="code" class="code" placeholder="请输入密码">
        </form>
               <mt-button type="primary" size="large" @click='onTap()'>登录</mt-button>

        
    </div>
</template>
<script>
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      mobile: "",
      code: ""
    };
  },
  methods: {
    onTap() {
      var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      var passReg = /^[0-9A-Za-z]{6,15}$/;
      // var mobile = reg.test(this.mobile);
      if (this.mobile == "") {
        Toast({
          message: "手机号不能为空！",
          duration: 1000
        });
        return;
      } else if (!reg.test(this.mobile)) {
        Toast({
          message: "手机号格式不对",
          duration: 1000
        });
        return;
      } else {
        console.log(this.mobile);
      }
      if (this.code == "") {
        Toast({
          message: "密码不能为空",
          duration: 1000
        });
        return;
      }
      if (!passReg.test(this.code)) {
        Toast({
          message: "密码格式不正确",
          duration: 1000
        });
        return;
      } else {
        console.log(this.code);
        this.$router.push("/home");
      }
    }
  }
};
</script>
<style scoped>
</style>


